ads_v = audioDatastore(fullfile(dataset,"validation"), ...
    IncludeSubfolders=true, ...
    FileExtensions=".wav", ...
    LabelSource="foldernames");

isCommand = ismember(ads_v.Labels,commands);
isBackground = ismember(ads_v.Labels,background);
isUnknown = ~(isCommand|isBackground);

includeFraction = 0.2; % Fraction of unknowns to include.
idx = find(isUnknown);
idx = idx(randperm(numel(idx),round((1-includeFraction)*sum(isUnknown))));
isUnknown(idx) = false;

ads_v.Labels(isUnknown) = categorical("unknown");

adsValidation = subset(ads_v,isCommand|isUnknown|isBackground);
adsValidation.Labels = removecats(adsValidation.Labels);
